﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;

namespace takeabreak
{
    public class C_MainForm
    {
        //Timer timer;
        int SUM = 0;
        int MAX = 0;
        bool status = false;
        List<string> timeList = new List<string>();
        public C_MainForm( int Max = 60)
        {
            //timer.Interval = 1000;
            MAX = Max;
            //timer.Start();
        }
        public void SetMax(int Max)
        {
            MAX = Max;
        }
        public void Clear()
        {
            timeList.Clear();
        }
        public void Add()
        {
            if (timeList.Count() == 0)
            {
                timeList.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
                return;
            }
            if (timeList[timeList.Count()-1] != DateTime.Now.ToString("yyyy-MM-dd HH:mm"))
            {
                if (timeList.Count() >= MAX)
                {
                    Minus();
                }
                timeList.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
            }
        }

        public void Minus()
        {
            if (timeList.Count()>0)
            {
                try
                {
                    //for (int i = 0; i < 3; i++)
                    //{
                    timeList.RemoveAt(timeList.Count() - 1);
                    //}
                }
                catch (Exception)
                {
                    timeList.RemoveAt(timeList.Count() - 1);
                }
                
            }
        }
        public int GetCount()
        {
            return timeList.Count();
        }
        public void SetStatus(bool Flag)
        {
            status = Flag;
        }
        internal bool GetStatus()
        {
            //throw new NotImplementedException();
            bool _status = status;
            status = false;
            return _status;
        }
    }
}
